package cn.zhixiangsingle.controller.gasBase;


import cn.zhixiangsingle.controller.slipperyBase.SlipperyBaseController;
import cn.zhixiangsingle.entity.base.user.User;
import cn.zhixiangsingle.entity.gas.GasBase.dto.GasBaseDTO;
import cn.zhixiangsingle.service.gasBase.GasBaseService;
import cn.zhixiangsingle.service.site.SiteService;
import cn.zhixiangsingle.web.responsive.IStatusMessage;
import cn.zhixiangsingle.web.responsive.ResultBean;
import com.alibaba.dubbo.config.annotation.Reference;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author zn
 * @description 瓦斯泄漏基础信息view
 * @date 2019/11/16 14:21
 * @Copyright: 2019 www.zhixiangyun.net Inc. All rights reserved.
 * 注意：本内容仅限于浙江智飨科技内部传阅，禁止外泄以及用于其他的商业目
 */

@Controller
@RequestMapping("/gasBase")
public class GasBaseController {
    private static final Logger logger = LoggerFactory
            .getLogger(SlipperyBaseController.class);
    @Reference(version = "1.0.0")
    private SiteService siervice;
    @Reference(version = "1.0.0")
    private GasBaseService gasBaseService;

    /**
     * @描述
     * @参数 []
     * @返回值 org.springframework.web.servlet.ModelAndView
     * @创建人 zn
     * @创建时间 2019/11/14
     * @修改人和其它信息
     */
    @RequestMapping(value = "/getListPage", method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView getListPage() {
        logger.debug("地面积水基础信息维护信息列表！");
        ModelAndView mav = new ModelAndView("/cgcc/tjjjcxx/tjjjcxxwh");
        try {
            mav.addObject("msg", "ok");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("跳转地面积水基础信息维护列表异常！", e);
        }
        return mav;
    }


    /**
     * @描述
     * @参数 [gasBaseDTO]
     * @返回值 cn.zhixiangsingle.web.responsive.ResultBean
     * @创建人 zn
     * @创建时间 2019/11/14
     * @修改人和其它信息
     */

    @PostMapping(value = "/getSlipperyBaseList")
    @ResponseBody
    public ResultBean getGasBaseList(GasBaseDTO GasBaseDTO) {
        logger.debug("获取添加剂基础信息维护列表！ GasBaseDTO = " + GasBaseDTO);
        ResultBean resultBean = new ResultBean();
        try {
            User existUser = (User) SecurityUtils.getSubject().getPrincipal();
            GasBaseDTO.setUserId(existUser.getId());
            resultBean = gasBaseService.findGasBaseList(GasBaseDTO);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("获取瓦斯泄漏基础信息维护列表异常！", e);
            resultBean.setSuccess(false);
            resultBean.setResultCode(IStatusMessage.SystemStatus.ERROR.getCode());
            resultBean.setMsg(IStatusMessage.SystemStatus.ERROR.getMessage());
        }
        return resultBean;
    }


}
